package com.litbw.publicobservable;

import com.litbw.event.Event;
import com.litbw.user.User;

/**
 * The EventDetailMessage is used to send signals regarding registration
 * for events.
 * @author Trygve Stageberg
 *
 */
public class RegisterMessage extends SimpleMessage {

	/**
	 * ADD REGISTRATION SIGNALS HERE AS NECESSARY.
	 * 
	 * The EventDetailSignal enumeration describes signals which may be sent
	 * either alone or along with Event data to observers which much take
	 * action on this data.
	 * 
	 * @author Trygve Stageberg
	 *
	 */
	public static enum RegisterSignal {
		UPDATE,
		CLEAR
	}
	
	/**
	 * The signal stored with this message.
	 */
	private final RegisterSignal signal;
	
	/**
	 * The Event data, if any, stored with this message.
	 */
	private final Event event;
	
	/**
	 * The User data, if any, stored with this message.
	 */
	private final User user;
	
	/**
	 * Create a new RegisterMessage supplying a signal and defaulting the
	 * Event data to null.
	 * @param sig The signal to send.
	 */
	public RegisterMessage(final RegisterSignal sig) {
		this(sig, null, null);
	}
	
	/**
	 * Create a new RegisterMessage supplying both a signal and Event data
	 * (which may be null).
	 * @param sig The signal to send.
	 * @param e The Event data, if any, to send along with the signal.
	 */
	public RegisterMessage(final RegisterSignal sig, final Event e, final User u) {
		
		if (sig == null)
			throw new IllegalArgumentException("must specify a signal");
		
		signal = sig;
		event = e;
		user = u;
		
	}
	
	/**
	 * Get the signal stored in this message.
	 * @return A EventDetailSignal reference.
	 */
	public final RegisterSignal getSignal() {
		return signal;
	}
	
	/**
	 * Get the Event data, if any, which is stored in this message.
	 * @return An Event object with data, or null if no Event was sent.
	 */
	public final Event getEvent() {
		return event;
	}
	
	/**
	 * Get the User data, if any, which is stored in this message.
	 * @return A User object with data, or null if no User was sent.
	 */
	public final User getUser() {
		return user;
	}
	
}
